package com.oriole.api.module.sys.controller;

import com.oriole.api.module.sys.service.ISysJobService;
import com.oriole.common.constant.ResultModel;
import com.oriole.entity.sys.SysJob;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.quartz.SchedulerException;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Created by IntelliJ IDEA.
 *
 * @author doublelife
 * Date: 2020/9/20 22:46
 * description: 系统job
 */
@Api(value = "ApiSysJobController", tags = {"系统job"})
@RestController
@RequestMapping("/api/sysJob")
public class ApiSysJobController {

    @Resource
    private ISysJobService jobService;

    @ApiOperation(value = "任务调度状态修改")
    @PostMapping("/changeStatus")
    public ResultModel<Object> changeStatus(SysJob job) throws SchedulerException {
        SysJob newJob = jobService.findById(job.getId());
        newJob.setStatus(job.getStatus());
        jobService.changeStatus(newJob);
        return ResultModel.success();
    }

}
